﻿//Change user language
$(document).ready(function() {
$("#language").change(function() {
        var form = $(this).parents('form');
        form.submit();
    });
});

//Change markup mode to view or design
$(document).ready(function() {
    $(".markupMode").change(function() {
        var form = $(this).parents('form');
        form.submit();
    });
});

//Menu
$(document).ready(function() {
    $(".menu-item li").mouseover(function() {
        $(this).find(".sub-menu").css("display", "block");
        $(this).find(".sub-menu .menu-item-title").css("background-position", "0 -28px");
        $(this).find(".sub-menu .menu-item-title span").css("background-position", "100% -28px");
    });

    $(".menu-item li").mouseout(function() {
        $(this).find(".sub-menu").css("display", "none");
        $(this).find(".sub-menu .menu-item-title").css("background-position", "0 0px");
        $(this).find(".sub-menu .menu-item-title span").css("background-position", "100% 5px");
    });
});

//Collapsable panel
$(document).ready(function() {
    $(".collapsablePanelImageContainer").click(function() {
        var item = $(this).parent().find(".collapsablePanelContent");
        if (item.css("display") == 'none') {
            $(this).parent().find(".collapsablePanelContent").slideDown(100);
            $(this).children().removeClass("collapsablePanelCollapsedImage");
            $(this).children().addClass("collapsablePanelExpandedImage");
        }
        else {
            $(this).parent().find(".collapsablePanelContent").slideUp(100);
            $(this).children().removeClass("collapsablePanelExpandedImage");
            $(this).children().addClass("collapsablePanelCollapsedImage");
        }
    });
});

//Module context menu actions
$(document).ready(function() {
    $(".pageActions").mouseover(function() {
        $(this).find(".sub-menu").css("display", "block");
    });
    $(".pageActions").mouseout(function() {
        $(this).find(".sub-menu").css("display", "none");
    });
});


//Submits form
function submitForm(item, action) {
    var form = document.getElementById(item);
    form.action = action;
    form.submit();
    return true;
}

jQuery(document).ready(function() {
    jQuery("abbr.timeago").timeago();
});